<#macro form id class ex>
    <form id="${id}" class="${class}" ${ex}>
        <#nested >
    </form>
</#macro>

<#macro formNovalidate id='' class='' htmlEx="">
    <form id="${id}" class="${class}" novalidate ${htmlEx}>
        <#nested >
    </form>
</#macro>
<#macro InputText name,placeholder='',autocomplete=true,vaid=''>
    <input class="form-control form-control-sm"  type="text"
        name="name" id="f-input_${name}"
        placeholder="${placeholder}"
        autocomplete="${autocomplete?then('on','off')}"
        ${vaid}
    >
</#macro>
<#macro Button
theme='primary' type='submit' text='提交' htmlEx=''>
    <button class="btn btn-space btn-${theme}"
            type="${type}" ${htmlEx}
    >
        ${text}
    </button>
</#macro>
<#macro FormBuilder id,formModel>
    <form id="${id}" action="/aaaa" class="fast-form">
        <#list formModel.formFields as field>
            <div class="form-group row">
                <label class="col-md-1 col-form-label text-sm-right" for="input-menu_name">
                ${field.name}:
                </label>
                <div class="col-md-3">
                <#switch field.type>
                    <#case 'text'>
                        <@InputText name=field.key
                        placeholder=field.placeholder
                        autocomplete=field.autocomplete
                        vaid=field.rules
                        >
                        </@InputText>
                        <#break>
                </#switch>
                </div>
            </div>
        </#list>
        <div class="form-group row">
            <label class="col-md-1 col-form-label text-sm-right">
            </label>
            <div class="col-md-3">
                <@Button text=formModel.submitName>
                </@Button>
                <#if formModel.canCancel>
                    <@Button text='取消' type='button' theme='secondary'
                        htmlEx='onclick="history.back()"'>
                    </@Button>
                </#if>

            </div>
        </div>
    </form>
</#macro>